package com.huluobo.a2109mouthdemo.splash;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;

import com.huluobo.a2109mouthdemo.MainActivity;
import com.huluobo.a2109mouthdemo.R;
import com.huluobo.a2109mouthdemo.base.BaseActivity;
import com.huluobo.a2109mouthdemo.login.LoginActivity;
import com.huluobo.a2109mouthdemo.view.MyView;

public class SplashActivity extends BaseActivity<SplashContract.View, SplashPresenter> implements SplashContract.View {

    private MyView myView;

    @Override
    protected void initData() {
        presenter = new SplashPresenter();
    }

    @Override
    protected void initView() {
        myView = findViewById(R.id.splash_my_view);
        myView.start(1);
        myView.setOnAnimEndListener(new MyView.OnAnimEndListener() {
            @Override
            public void onAnimEnd() {
                presenter.checkLoggedInBefore();
            }
        });
    }

    @Override
    protected int bindLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    public void isLoggedIn() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    @Override
    public void isNotLoggedIn() {
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
        finish();
    }
}